package org.devastra.arcinspect;
import java.io.File;

import org.apache.tools.ant.Task;
import org.devastra.arcinspect.analyzer.ProjectAnalyzer;
import org.devastra.arcinspect.analyzer.data.ProjectData;
import org.devastra.arcinspect.eval.DependencyEvaluator;
import org.devastra.arcinspect.plan.ArchitecturePlan;
import org.devastra.arcinspect.report.ArcReporter;


/**
 * This class will support an Ant Task in the following manner
 * @author ashutosh
 * 
 * <DependencyCheck projectSource="" output="" plan=""/>
 *
 */
public class DependencyCheckTask extends Task {
	
	private String projectSource;
	private String outputFolder;
	private String planFile;
	
	public DependencyCheckTask() {
		// TODO Auto-generated constructor stub
	}

	public void setProjectSource(String _src) {
		projectSource = _src;
	}
	
	public void setOutput(String _output) {
		outputFolder = _output;
	}
	
	public void setPlan(String _plan) {
		planFile = _plan;
	}
	
	public void execute() {
		ProjectData projData = ProjectData.getInstance("Test", projectSource);
		ProjectAnalyzer analyzer = new ProjectAnalyzer(projData);
		projData = analyzer.analyze();
		
		ArchitecturePlan plan = ArchitecturePlan.getArchitecturePlan(new File(planFile));
		
		DependencyEvaluator depEval = new DependencyEvaluator(plan);
		depEval.checkDependency();
		
		ArcReporter reporter = new ArcReporter();
		reporter.generateHtmlReport(projData, outputFolder);
		
	}
}
